package cn.xiaolang.function.sort_algorithm;

import java.util.Random;

/**
 * 排序示例
 *
 * @author fuhw/DeanKano
 * @date 2018-11-28
 */
public class SortSample {

	public static void main(String[] args) {
		int[] a = { 10, 3, 9, 5, 8, 9, 5, 11, 4, 9, 7, 3, 2, 5, 8 };
		choiceSortSample(a);
	}

	/**
	 * 插入排序
	 */
	public static void insertSortSample(int[] a) {
		ISort sortAlgorithm = new InsertSort();
		sortAlgorithm.sortWithMonitor(a);
	}

	/**
	 * 希尔排序
	 */
	public static void shellSortSample(int[] a) {
		ISort sortAlgorithm = new ShellSort();
		sortAlgorithm.sortWithMonitor(a);
	}

	/**
	 * 选择排序
	 */
	public static void choiceSortSample(int[] a) {
		ISort sortAlgorithm = new ChoiceSort();
		sortAlgorithm.sortWithMonitor(a);
	}

	/**
	 * 获取随机int类型数组
	 */
	public static int[] getRandomArs(int length, int max) {
		int rs[] = new int[length];
		Random random = new Random();
		for (int i = 0; i < length; i++) {
			rs[i] = random.nextInt(max);
		}
		return rs;
	}

}
